﻿using System;
using System.Linq;
using System.Collections.Generic;

using SharedGenomics.Core;
using SharedGenomics.Annotations;

namespace SharedGenomics.Workbench.Annotations
{
    public class SucceededAnnotationRequestResult : AnnotationRequestResult
    {
        public SucceededAnnotationRequestResult(AnnotationKey key, object rootValue, IAnnotation annotation, IEnumerable<AnnotationValue> values)
            : base(key, rootValue)
        {
            annotation.ThrowIfNull("annotation");

            this.Annotation = annotation;
            this.Status = AnnotationRequestStatus.Finished;

            //add all non-null values
            (values ?? Enumerable.Empty<AnnotationValue>()).Where(v => v != null).ForEach(v => this.AddValue(v));
        }
    }
}
